package com.InterestingExercises.电影信息系统Object_Oriented;

/**
 * 电影实体操作类
 */
public class FilmOperator {
    private Film[] films;//电影实体类数组用于存储不止一部电影

    //有参构造函数
    public FilmOperator(Film[] films) {
        this.films = films;//数组赋给数组
    }

    //展示系统全部电影信息
    public void showAllFilms() {
        System.out.println("╭───────────────────╮");
        System.out.println("│ 系统全部电影信息如下  │");
        System.out.println("╰───────────────────╯");
        for (int i = 0; i < films.length; i++) {
            System.out.println("╭───────────────────╮");
            System.out.printf("│编号:%-15d│\n", this.films[i].getId());
            System.out.println("│───────────────────│");
            System.out.printf("│名称:%-13s│\n", this.films[i].getName());
            System.out.println("│───────────────────│");
            System.out.printf("│票价:%-15.1f│\n", this.films[i].getPrice());
            System.out.println("│───────────────────│");
            System.out.printf("│评分:%-15.1f│\n", this.films[i].getScore());
            System.out.println("│───────────────────│");
            System.out.printf("│导演:%-13s│\n", this.films[i].getDirector());
            System.out.println("│───────────────────│");
            System.out.printf("│主演:%-13s│\n", this.films[i].getActor());
            System.out.println("│───────────────────│");
            System.out.printf("│其他信息:%-9s│\n", this.films[i].getInfo());
            System.out.println("╰───────────────────╯\n");
        }
    }


    //查询某个电影详情
    public void searchFilmById(int id) {
        System.out.println("╭───────────────────╮");
        System.out.println("│ 开始查找id = " + id + "的电影 │");
        System.out.println("╰───────────────────╯");
        for (int i = 0; i < films.length; i++) {
            if (this.films[i].getId() == id) {
                System.out.println("╭───────────────────╮");
                System.out.println("│  该电影详细信息如下  │");
                System.out.println("│───────────────────│");
                System.out.printf("│编号:%-15d│\n", this.films[i].getId());
                System.out.println("│───────────────────│");
                System.out.printf("│名称:%-13s│\n", this.films[i].getName());
                System.out.println("│───────────────────│");
                System.out.printf("│票价:%-15.1f│\n", this.films[i].getPrice());
                System.out.println("│───────────────────│");
                System.out.printf("│评分:%-15.1f│\n", this.films[i].getScore());
                System.out.println("│───────────────────│");
                System.out.printf("│导演:%-13s│\n", this.films[i].getDirector());
                System.out.println("│───────────────────│");
                System.out.printf("│主演:%-13s│\n", this.films[i].getActor());
                System.out.println("│───────────────────│");
                System.out.printf("│其他信息:%-9s│\n", this.films[i].getInfo());
                System.out.println("╰───────────────────╯\n");
                return;
            }
        }
        System.out.println("\n抱歉没有找到该电影详情!\n");
    }
}
